package com.zzyweb.rentalcarsys.exception;


import com.zzyweb.rentalcarsys.utils.ResponseObject;
import org.apache.ibatis.builder.BuilderException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author zhiyi
 * @date 9/23/25
 **/
@RestControllerAdvice
public class MyGlobalExceptionHandler {

    @ExceptionHandler(BuilderException.class)
    public ResponseObject handleBusinessException(BusinessException e) {
        e.printStackTrace();
        return ResponseObject.error().code(e.getCode()).msg(e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public ResponseObject handleException(Exception e) {
        e.printStackTrace();
        return ResponseObject.error().msg(e.getMessage());
    }

}
